#ifndef _ADRC_H
#define _ADRC_H

#include "motor.h"

typedef struct {
    int16_t wc;
    int16_t wo;
    int16_t b0;
    int16_t ts;
    uint16_t beta0;
    uint16_t beta1;
    uint16_t lsef_coef;
    int16_t z[2];
    int16_t dz[2];
    int16_t u;
    int16_t out_up;
    int16_t out_low;
} Ladrc_t;

typedef struct TD
{
		float h;//time step size
		float r;//transition parameter
	  float x1;//transition value
	  float x2;//derivative of the transition value
}TD_Obj;

extern TD_Obj ltd;
extern TD_Obj filter;
extern Ladrc_t ladrc_vel;

void  TD_Init(TD_Obj *td,float h,float r);
void  TD(TD_Obj *td,float x);
void TD_Reset(TD_Obj *td);
void Ladrc_setCtrlParm(Ladrc_t *ladrc, int16_t wc, int16_t wo, int16_t b0);
int16_t Ladrc_1st(Ladrc_t *ladrc, int16_t ref, int16_t fb);

#endif
